package com.example.yls.demoa;

import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    private PaletteView mPaletteView;
    private Button clear;
    private Button back;
    private Button redo;
    private Button xiangpicha;
    private Button save;
    private Button draw;
    private Button draw_sq;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mPaletteView=findViewById(R.id.My_PaletteView);
        clear=findViewById(R.id.clear);
        back=findViewById(R.id.back);
        redo=findViewById(R.id.redo);
        draw_sq=findViewById(R.id.draw_sq);
        xiangpicha=findViewById(R.id.eraser);
        save=findViewById(R.id.save);
        draw=findViewById(R.id.draw);

        draw_sq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mPaletteView.SetPaintMode(mPaletteView.REQ);
            }
        });
        draw.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mPaletteView.setMode(PaletteView.Mode.DRAW);
            }
        });
        clear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mPaletteView.clear();
            }
        });
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mPaletteView.undo();
            }
        });
        save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });
        redo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mPaletteView.redo();
            }
        });
        xiangpicha.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mPaletteView.setEraserSize(70);
                mPaletteView.setMode(PaletteView.Mode.ERASER);

            }
        });

    }
}
